<template>
    <div>

    </div>
</template>

<script>
    import {userType} from "../util/base";
    import Cookies from 'js-cookie'
    import {useRouter} from "vue-router";
    import {useStore} from 'vuex'
    export default {
        name: "home",
        setup(){
            let router = useRouter();
            let store = useStore();
            let user_info = () =>{
                let token = Cookies.get('token');
                console.log('token',token);
                if(token){
                    let {user_type,user_name} = userType(token);
                    console.log('user_type',user_type)
                    store.commit('setUserType',user_type)
                    store.commit('setUserName',user_name)
                    store.commit('setToken',token)
                    if (user_type === 1){
                        router.push('/user')
                    }else if(user_type === 2){
                        router.push('/org')
                    }else if (user_type === 3){
                        router.push('/admin')
                    }else{
                        router.push('/login')
                    }
                }else{
                    router.push('/login')
                }
            }
            user_info();
            return{

            }
        }
    }
</script>

<style scoped>

</style>
